import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { TransformInterceptor } from './interceptor/transform.interceptor';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { HttpExceptionFilter } from './filters/http-exception.filter';
import { ValidationPipe } from '@nestjs/common';
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  app.setGlobalPrefix('api');
  const options = new DocumentBuilder()
    .setTitle('nest-blog')
    .setDescription('The blog API description')
    .setVersion('1.0')
    .addTag('curd')
    .addBearerAuth()
    .build();
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('api-doc', app, document);

  app.useGlobalFilters(new HttpExceptionFilter());
  app.useGlobalInterceptors(new TransformInterceptor());

  //生产环境要禁用，错误提示信息
  app.useGlobalPipes(
    new ValidationPipe({
      //  disableErrorMessages: true,
    }),
  );

  await app.listen(3009);
  console.log('服务好了----------' + new Date());
  console.log(
    '\n',
    'api预览地址: http://localhost:3009/api-doc/',
    '\n',
    '接口地址: http://localhost:3009/',
  );
}
bootstrap();

//修改11.0修改bug，全局
